<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API测试页面</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3f37c9;
            --accent-color: #f72585;
            --light-color: #f8f9fa;
            --dark-color: #212529;
            --success-color: #06ffa5;
            --warning-color: #ffbe0b;
            --info-color: #00b4d8;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f5f7fb;
            color: #333;
            line-height: 1.6;
        }
        
        /* 顶部导航栏 */
        .navbar {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            padding: 1rem 0;
        }
        
        .navbar-brand {
            font-weight: 700;
            font-size: 1.5rem;
            color: white !important;
            display: flex;
            align-items: center;
        }
        
        .navbar-brand i {
            margin-right: 10px;
            font-size: 1.8rem;
        }
        
        .nav-link {
            color: rgba(255, 255, 255, 0.85) !important;
            font-weight: 500;
            margin: 0 10px;
            transition: all 0.3s ease;
            border-radius: 4px;
            padding: 8px 16px !important;
        }
        
        .nav-link:hover, .nav-link.active {
            background-color: rgba(255, 255, 255, 0.15);
            color: white !important;
        }
        
        /* 主要内容区域 */
        .main-container {
            padding: 2rem 0;
        }
        
        /* 卡片样式 */
        .custom-card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            transition: all 0.3s ease;
        }
        
        .custom-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
        }
        
        .card-header-custom {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
            padding-bottom: 0.75rem;
            border-bottom: 1px solid #e9ecef;
        }
        
        .card-title {
            font-size: 1.25rem;
            font-weight: 600;
            color: var(--dark-color);
            margin: 0;
            display: flex;
            align-items: center;
        }
        
        .card-title i {
            margin-right: 10px;
            color: var(--primary-color);
        }
        
        /* 按钮样式 */
        .btn-custom {
            border-radius: 6px;
            font-weight: 500;
            padding: 8px 16px;
            transition: all 0.3s ease;
            margin: 5px;
        }
        
        .btn-primary-custom {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            border: none;
            color: white;
        }
        
        .btn-primary-custom:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(67, 97, 238, 0.3);
        }
        
        .btn-success-custom {
            background: linear-gradient(135deg, var(--success-color), #00b388);
            border: none;
            color: white;
        }
        
        .btn-success-custom:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(6, 255, 165, 0.3);
        }
        
        .btn-info-custom {
            background: linear-gradient(135deg, var(--info-color), #0077b6);
            border: none;
            color: white;
        }
        
        .btn-info-custom:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 180, 216, 0.3);
        }
        
        .btn-warning-custom {
            background: linear-gradient(135deg, var(--warning-color), #fb8500);
            border: none;
            color: white;
        }
        
        .btn-warning-custom:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(255, 190, 11, 0.3);
        }
        
        .btn-secondary-custom {
            background: linear-gradient(135deg, #6c757d, #495057);
            border: none;
            color: white;
        }
        
        .btn-secondary-custom:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
        }
        
        /* API结果区域 */
        .api-result {
            background-color: #f8f9fa;
            border-radius: 8px;
            padding: 1rem;
            margin-top: 1rem;
            max-height: 300px;
            overflow-y: auto;
            font-family: 'Courier New', monospace;
            font-size: 0.9rem;
            line-height: 1.5;
            border: 1px solid #e9ecef;
        }
        
        .api-result pre {
            margin: 0;
            white-space: pre-wrap;
            word-wrap: break-word;
        }
        
        /* 统计卡片 */
        .stat-card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            transition: all 0.3s ease;
            border-left: 4px solid var(--primary-color);
            position: relative;
            overflow: hidden;
        }
        
        .stat-card::before {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 100px;
            height: 100px;
            background: linear-gradient(135deg, rgba(67, 97, 238, 0.1), rgba(247, 37, 133, 0.1));
            border-radius: 50%;
            transform: translate(30px, -30px);
        }
        
        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
        }
        
        .stat-card.users {
            border-left-color: var(--info-color);
        }
        
        .stat-card.roles {
            border-left-color: var(--success-color);
        }
        
        .stat-card.permissions {
            border-left-color: var(--warning-color);
        }
        
        .stat-card.views {
            border-left-color: var(--accent-color);
        }
        
        .stat-icon {
            width: 60px;
            height: 60px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            color: white;
            margin-bottom: 1rem;
        }
        
        .stat-icon.users {
            background: linear-gradient(135deg, #00b4d8, #0077b6);
        }
        
        .stat-icon.roles {
            background: linear-gradient(135deg, #06ffa5, #00b388);
        }
        
        .stat-icon.permissions {
            background: linear-gradient(135deg, #ffbe0b, #fb8500);
        }
        
        .stat-icon.views {
            background: linear-gradient(135deg, #f72585, #b5179e);
        }
        
        .stat-value {
            font-size: 2.5rem;
            font-weight: 700;
            color: var(--dark-color);
            margin-bottom: 0.5rem;
        }
        
        .stat-label {
            font-size: 1rem;
            color: #6c757d;
            font-weight: 500;
        }
        
        /* 调试信息区域 */
        .debug-content {
            background-color: #f8f9fa;
            border-radius: 8px;
            padding: 1rem;
            font-family: 'Courier New', monospace;
            font-size: 0.9rem;
            max-height: 300px;
            overflow-y: auto;
            white-space: pre-wrap;
            line-height: 1.5;
        }
        
        .debug-line {
            margin-bottom: 5px;
            padding: 4px 0;
        }
        
        .debug-timestamp {
            color: #6c757d;
            font-weight: 500;
        }
        
        /* 加载动画 */
        .loading {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid rgba(67, 97, 238, 0.3);
            border-radius: 50%;
            border-top-color: var(--primary-color);
            animation: spin 1s ease-in-out infinite;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        /* 响应式调整 */
        @media (max-width: 768px) {
            .stat-value {
                font-size: 2rem;
            }
            
            .navbar-brand {
                font-size: 1.2rem;
            }
        }
    </style>
</head>
<body>
    <!-- 顶部导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark">
        <div class="container">
            <a class="navbar-brand" href="#">
                <i class="bi bi-bug"></i>
                API测试页面
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="index.html">
                            <i class="bi bi-house-door"></i> 首页
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" href="#">
                            <i class="bi bi-bug"></i> API测试
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#" onclick="toggleDebugInfo(); return false;">
                            <i class="bi bi-terminal"></i> 调试
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 主要内容区域 -->
    <div class="container main-container">
        <!-- API测试区域 -->
        <div class="row">
            <div class="col-12">
                <div class="custom-card">
                    <div class="card-header-custom">
                        <h2 class="card-title">
                            <i class="bi bi-code-slash"></i>
                            API端点测试
                        </h2>
                    </div>
                    <div class="d-flex flex-wrap">
                        <button class="btn btn-primary-custom btn-custom" onclick="testUsersAPI()">
                            <i class="bi bi-people"></i> 测试用户API
                        </button>
                        <button class="btn btn-success-custom btn-custom" onclick="testRolesAPI()">
                            <i class="bi bi-person-badge"></i> 测试角色API
                        </button>
                        <button class="btn btn-info-custom btn-custom" onclick="testPermissionsAPI()">
                            <i class="bi bi-key"></i> 测试权限API
                        </button>
                        <button class="btn btn-warning-custom btn-custom" onclick="testPageViewsAPI()">
                            <i class="bi bi-eye"></i> 测试页面访问统计API
                        </button>
                        <button class="btn btn-secondary-custom btn-custom" onclick="testAllAPIs()">
                            <i class="bi bi-lightning"></i> 测试所有API
                        </button>
                    </div>
                    
                    <div id="apiResults" class="api-result">
                        <p>点击上方按钮测试API...</p>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 统计数据区域 -->
        <div class="row">
            <div class="col-12">
                <div class="custom-card">
                    <div class="card-header-custom">
                        <h2 class="card-title">
                            <i class="bi bi-graph-up"></i>
                            统计数据
                        </h2>
                        <button class="btn btn-primary-custom btn-custom" onclick="loadStatistics()">
                            <i class="bi bi-arrow-clockwise"></i> 加载统计数据
                        </button>
                    </div>
                    
                    <div class="row">
                        <div class="col-lg-3 col-md-6">
                            <div class="stat-card users">
                                <div class="stat-icon users">
                                    <i class="bi bi-people"></i>
                                </div>
                                <div class="stat-value" id="userCount">-</div>
                                <div class="stat-label">用户数量</div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6">
                            <div class="stat-card roles">
                                <div class="stat-icon roles">
                                    <i class="bi bi-person-badge"></i>
                                </div>
                                <div class="stat-value" id="roleCount">-</div>
                                <div class="stat-label">角色数量</div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6">
                            <div class="stat-card permissions">
                                <div class="stat-icon permissions">
                                    <i class="bi bi-key"></i>
                                </div>
                                <div class="stat-value" id="permissionCount">-</div>
                                <div class="stat-label">权限数量</div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6">
                            <div class="stat-card views">
                                <div class="stat-icon views">
                                    <i class="bi bi-eye"></i>
                                </div>
                                <div class="stat-value" id="pageViewCount">-</div>
                                <div class="stat-label">页面访问次数</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 调试信息区域 -->
        <div class="row">
            <div class="col-12">
                <div class="custom-card" id="debugInfo" style="display: none;">
                    <div class="card-header-custom">
                        <h2 class="card-title">
                            <i class="bi bi-terminal"></i>
                            调试信息
                        </h2>
                        <button class="btn btn-outline-secondary btn-sm" onclick="clearDebugInfo()">
                            <i class="bi bi-trash"></i> 清空
                        </button>
                    </div>
                    <div class="debug-content" id="debugContent"></div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // API基础URL
        const baseUrl = '';
        
        // 切换调试信息显示
        function toggleDebugInfo() {
            const debugInfo = document.getElementById('debugInfo');
            if (debugInfo.style.display === 'none') {
                debugInfo.style.display = 'block';
            } else {
                debugInfo.style.display = 'none';
            }
        }
        
        // 清空调试信息
        function clearDebugInfo() {
            document.getElementById('debugContent').innerHTML = '';
        }
        
        // 更新调试信息
        function updateDebugInfo(message) {
            const debugContent = document.getElementById('debugContent');
            const timestamp = new Date().toLocaleTimeString();
            const debugLine = document.createElement('div');
            debugLine.className = 'debug-line';
            debugLine.innerHTML = `<span class="debug-timestamp">[${timestamp}]</span> ${message}`;
            debugContent.appendChild(debugLine);
            // 自动滚动到底部
            debugContent.scrollTop = debugContent.scrollHeight;
        }
        
        // 测试用户API
        async function testUsersAPI() {
            try {
                const response = await fetch(`${baseUrl}/api/users`);
                const data = await response.json();
                displayResult('用户API', response.status, data);
            } catch (error) {
                displayResult('用户API', 'Error', error.message);
            }
        }
        
        // 测试角色API
        async function testRolesAPI() {
            try {
                const response = await fetch(`${baseUrl}/api/roles`);
                const data = await response.json();
                displayResult('角色API', response.status, data);
            } catch (error) {
                displayResult('角色API', 'Error', error.message);
            }
        }
        
        // 测试权限API
        async function testPermissionsAPI() {
            try {
                const response = await fetch(`${baseUrl}/api/permissions`);
                const data = await response.json();
                displayResult('权限API', response.status, data);
            } catch (error) {
                displayResult('权限API', 'Error', error.message);
            }
        }
        
        // 测试页面访问统计API
        async function testPageViewsAPI() {
            try {
                const response = await fetch(`${baseUrl}/api/stats/page-views`);
                const data = await response.json();
                displayResult('页面访问统计API', response.status, data);
            } catch (error) {
                displayResult('页面访问统计API', 'Error', error.message);
            }
        }
        
        // 测试所有API
        async function testAllAPIs() {
            await testUsersAPI();
            await testRolesAPI();
            await testPermissionsAPI();
            await testPageViewsAPI();
        }
        
        // 显示API测试结果
        function displayResult(apiName, status, data) {
            const resultsDiv = document.getElementById('apiResults');
            const resultHtml = `
                <div class="mb-3">
                    <h5>${apiName} (状态码: ${status})</h5>
                    <pre>${JSON.stringify(data, null, 2)}</pre>
                </div>
            `;
            resultsDiv.innerHTML = resultHtml + resultsDiv.innerHTML;
        }
        
        // 获取统计数据
        async function loadStatistics() {
            try {
                // 显示加载中状态
                document.getElementById('userCount').innerHTML = '<div class="loading"></div>';
                document.getElementById('roleCount').innerHTML = '<div class="loading"></div>';
                document.getElementById('permissionCount').innerHTML = '<div class="loading"></div>';
                document.getElementById('pageViewCount').innerHTML = '<div class="loading"></div>';
                
                // 清空调试信息
                document.getElementById('debugContent').innerHTML = '';
                updateDebugInfo('开始获取统计数据...');
                
                // 获取用户数据
                try {
                    updateDebugInfo('正在获取用户数据...');
                    const usersResponse = await fetch(`${baseUrl}/api/users`);
                    updateDebugInfo(`用户API响应状态: ${usersResponse.status}`);
                    
                    if (!usersResponse.ok) {
                        throw new Error(`HTTP错误! 状态: ${usersResponse.status}`);
                    }
                    
                    const usersData = await usersResponse.json();
                    console.log('用户数据:', usersData);
                    updateDebugInfo(`用户数据: ${JSON.stringify(usersData)}`);
                    
                    // 检查数据结构
                    let userCount = 0;
                    if (usersData && typeof usersData === 'object') {
                        if (usersData.code === 200 && usersData.data) {
                            if (Array.isArray(usersData.data)) {
                                userCount = usersData.data.length;
                            } else if (typeof usersData.data === 'object' && usersData.data.list) {
                                userCount = usersData.data.list.length;
                            } else if (typeof usersData.data === 'object' && usersData.data.records) {
                                userCount = usersData.data.records.length;
                            } else if (typeof usersData.data === 'number') {
                                userCount = usersData.data;
                            }
                        } else if (usersData.success === true && usersData.data) {
                            if (Array.isArray(usersData.data)) {
                                userCount = usersData.data.length;
                            } else if (typeof usersData.data === 'object' && usersData.data.list) {
                                userCount = usersData.data.list.length;
                            } else if (typeof usersData.data === 'object' && usersData.data.records) {
                                userCount = usersData.data.records.length;
                            } else if (typeof usersData.data === 'number') {
                                userCount = usersData.data;
                            }
                        }
                    }
                    
                    document.getElementById('userCount').textContent = userCount;
                    updateDebugInfo(`用户数量: ${userCount}`);
                } catch (error) {
                    console.error('获取用户数据失败:', error);
                    updateDebugInfo(`获取用户数据失败: ${error.message}`);
                    document.getElementById('userCount').textContent = '获取失败';
                }
                
                // 获取角色数据
                try {
                    updateDebugInfo('正在获取角色数据...');
                    const rolesResponse = await fetch(`${baseUrl}/api/roles`);
                    updateDebugInfo(`角色API响应状态: ${rolesResponse.status}`);
                    
                    if (!rolesResponse.ok) {
                        throw new Error(`HTTP错误! 状态: ${rolesResponse.status}`);
                    }
                    
                    const rolesData = await rolesResponse.json();
                    console.log('角色数据:', rolesData);
                    updateDebugInfo(`角色数据: ${JSON.stringify(rolesData)}`);
                    
                    // 检查数据结构
                    let roleCount = 0;
                    if (rolesData && typeof rolesData === 'object') {
                        if (rolesData.code === 200 && rolesData.data) {
                            if (Array.isArray(rolesData.data)) {
                                roleCount = rolesData.data.length;
                            } else if (typeof rolesData.data === 'object' && rolesData.data.list) {
                                roleCount = rolesData.data.list.length;
                            } else if (typeof rolesData.data === 'object' && rolesData.data.records) {
                                roleCount = rolesData.data.records.length;
                            } else if (typeof rolesData.data === 'number') {
                                roleCount = rolesData.data;
                            }
                        } else if (rolesData.success === true && rolesData.data) {
                            if (Array.isArray(rolesData.data)) {
                                roleCount = rolesData.data.length;
                            } else if (typeof rolesData.data === 'object' && rolesData.data.list) {
                                roleCount = rolesData.data.list.length;
                            } else if (typeof rolesData.data === 'object' && rolesData.data.records) {
                                roleCount = rolesData.data.records.length;
                            } else if (typeof rolesData.data === 'number') {
                                roleCount = rolesData.data;
                            }
                        }
                    }
                    
                    document.getElementById('roleCount').textContent = roleCount;
                    updateDebugInfo(`角色数量: ${roleCount}`);
                } catch (error) {
                    console.error('获取角色数据失败:', error);
                    updateDebugInfo(`获取角色数据失败: ${error.message}`);
                    document.getElementById('roleCount').textContent = '获取失败';
                }
                
                // 获取权限数据
                try {
                    updateDebugInfo('正在获取权限数据...');
                    const permissionsResponse = await fetch(`${baseUrl}/api/permissions`);
                    updateDebugInfo(`权限API响应状态: ${permissionsResponse.status}`);
                    
                    if (!permissionsResponse.ok) {
                        throw new Error(`HTTP错误! 状态: ${permissionsResponse.status}`);
                    }
                    
                    const permissionsData = await permissionsResponse.json();
                    console.log('权限数据:', permissionsData);
                    updateDebugInfo(`权限数据: ${JSON.stringify(permissionsData)}`);
                    
                    // 检查数据结构
                    let permissionCount = 0;
                    if (permissionsData && typeof permissionsData === 'object') {
                        if (permissionsData.code === 200 && permissionsData.data) {
                            if (Array.isArray(permissionsData.data)) {
                                permissionCount = permissionsData.data.length;
                            } else if (typeof permissionsData.data === 'object' && permissionsData.data.list) {
                                permissionCount = permissionsData.data.list.length;
                            } else if (typeof permissionsData.data === 'object' && permissionsData.data.records) {
                                permissionCount = permissionsData.data.records.length;
                            } else if (typeof permissionsData.data === 'number') {
                                permissionCount = permissionsData.data;
                            }
                        } else if (permissionsData.success === true && permissionsData.data) {
                            if (Array.isArray(permissionsData.data)) {
                                permissionCount = permissionsData.data.length;
                            } else if (typeof permissionsData.data === 'object' && permissionsData.data.list) {
                                permissionCount = permissionsData.data.list.length;
                            } else if (typeof permissionsData.data === 'object' && permissionsData.data.records) {
                                permissionCount = permissionsData.data.records.length;
                            } else if (typeof permissionsData.data === 'number') {
                                permissionCount = permissionsData.data;
                            }
                        }
                    }
                    
                    document.getElementById('permissionCount').textContent = permissionCount;
                    updateDebugInfo(`权限数量: ${permissionCount}`);
                } catch (error) {
                    console.error('获取权限数据失败:', error);
                    updateDebugInfo(`获取权限数据失败: ${error.message}`);
                    document.getElementById('permissionCount').textContent = '获取失败';
                }
                
                // 获取页面访问数据
                try {
                    updateDebugInfo('正在获取页面访问数据...');
                    const pageViewResponse = await fetch(`${baseUrl}/api/stats/page-views`);
                    updateDebugInfo(`页面访问API响应状态: ${pageViewResponse.status}`);
                    
                    if (!pageViewResponse.ok) {
                        throw new Error(`HTTP错误! 状态: ${pageViewResponse.status}`);
                    }
                    
                    const pageViewData = await pageViewResponse.json();
                    console.log('页面访问数据:', pageViewData);
                    updateDebugInfo(`页面访问数据: ${JSON.stringify(pageViewData)}`);
                    
                    // 检查数据结构
                    let pageViewCount = 0;
                    if (pageViewData && typeof pageViewData === 'object') {
                        if (pageViewData.code === 200 && pageViewData.data) {
                            if (typeof pageViewData.data === 'number') {
                                pageViewCount = pageViewData.data;
                            } else if (typeof pageViewData.data === 'object' && pageViewData.data.totalViews !== undefined) {
                                pageViewCount = pageViewData.data.totalViews;
                            } else if (typeof pageViewData.data === 'object' && pageViewData.data.count !== undefined) {
                                pageViewCount = pageViewData.data.count;
                            }
                        } else if (pageViewData.success === true && pageViewData.data) {
                            if (typeof pageViewData.data === 'number') {
                                pageViewCount = pageViewData.data;
                            } else if (typeof pageViewData.data === 'object' && pageViewData.data.totalViews !== undefined) {
                                pageViewCount = pageViewData.data.totalViews;
                            } else if (typeof pageViewData.data === 'object' && pageViewData.data.count !== undefined) {
                                pageViewCount = pageViewData.data.count;
                            }
                        }
                    }
                    
                    document.getElementById('pageViewCount').textContent = pageViewCount;
                    updateDebugInfo(`页面访问次数: ${pageViewCount}`);
                } catch (error) {
                    console.error('获取页面访问数据失败:', error);
                    updateDebugInfo(`获取页面访问数据失败: ${error.message}`);
                    document.getElementById('pageViewCount').textContent = '获取失败';
                }
                
                updateDebugInfo('所有统计数据获取完成');
                
            } catch (error) {
                console.error('获取统计数据失败:', error);
                updateDebugInfo(`获取统计数据失败: ${error.message}`);
                // 显示错误信息
                document.getElementById('userCount').textContent = '获取失败';
                document.getElementById('roleCount').textContent = '获取失败';
                document.getElementById('permissionCount').textContent = '获取失败';
                document.getElementById('pageViewCount').textContent = '获取失败';
            }
        }
        
        // 页面加载时自动获取统计数据
        document.addEventListener('DOMContentLoaded', function() {
            loadStatistics();
        });
    </script>
</body>
</html>